package com.share.web.action.attach.advertise;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.share.bean.attach.advertise.PositionSort;
import com.share.service.attach.advertise.PositionSortManager;
import com.share.web.action.base.BaseActionSupport;

@Controller
@Scope("prototype")
public class PositionSortAction extends BaseActionSupport{
 
	private static final long serialVersionUID = 1L;

	private PositionSort ps ;
	
	@Resource
	private PositionSortManager psmgr ;

	public String addPositionSort() throws Exception {
		
		this.psmgr.savePositionSortManager(ps) ;
		
		return SUCCESS ;
	}
	
	public String updatePs() throws Exception {
		this.psmgr.updatePositionSortManager(ps) ;
		this.getBaseform().getRequest().setAttribute("redirectUrl","/share/attach/positionSort!loadAllPs.action");
		return "pub_update_success" ;
	}
	
	public String deletePs() throws Exception {
		this.psmgr.deletePositionSortManager(ps.getPsId()) ;
		return SUCCESS ;
	}
	
	public String loadByIdPs() throws Exception {
		this.getBaseform().getRequest().setAttribute("ps",this.psmgr.loadByIdPositionSortManager(ps.getPsId())) ;
		return "updatePs" ;
	}

	public String loadAllPs() throws Exception {
		this.getBaseform().getRequest().setAttribute("psList",this.psmgr.findAllPositionSortManager()) ;
		
		if("addPi".equals(this.getBaseform().getType())) {
			return "addPi" ;
		} else {
			return "loadAll" ;
		}
	}

	public PositionSort getPs() {
		return ps;
	}

	public void setPs(PositionSort ps) {
		this.ps = ps;
	}

	public PositionSortManager getPsmgr() {
		return psmgr;
	}

	public void setPsmgr(PositionSortManager psmgr) {
		this.psmgr = psmgr;
	}
	
}
